var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    accountName:"",
    bankName:"",
    bankNo:"",
    bankDeposit:"",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.loadings();
  },

  //获取医生银行个人信息
  loadings: function() {
    var that = this;
    app.request({
      url: 'doctor/doctor/doctorBankInfo',
      data: {},
      success(res) {
        that.setData({
          accountName: res.data[0].accountName,
          bankName: res.data[0].bankName,
          bankNo: res.data[0].bankNo,
          bankDeposit: res.data[0].bankDeposit,
        })
      }
    })
  },
  //保存
  nextstep: function() {
    var accountName = this.data.accountName;
    var bankName = this.data.bankName;
    var bankNo = this.data.bankNo;
    var bankDeposit = this.data.bankDeposit;
    if (accountName == '') {
      wx.showToast({
        title: '请添加您的账户名称',
        icon: 'none',
        duration: 1000
      })
      return false;
    }
    if (bankName == "") {
      wx.showToast({
        title: '请输入您的银行名称',
        icon: 'none',
        duration: 1000
      })
      return false;
    }
    if (bankNo == "") {
      wx.showToast({
        title: '请输入您的银行账户',
        icon: 'none',
        duration: 1000
      })
      return false;
    }

    if (bankDeposit == "") {
      wx.showToast({
        title: '请输入您的开户行地址',
        icon: 'none',
        duration: 1000
      })
      return false;
    }
    app.request({
      url: 'doctor/doctor/editBankInfo',
      data: {
        accountName: accountName,
        bankName: bankName,
        bankNo: bankNo,
        bankDeposit: bankDeposit,
      },
      success(res) {
        wx.showToast({
          title: res.message,
          icon: 'success',
          duration: 1000
        })
        setTimeout(function () {
          wx.reLaunch({
            url: '../doctor-my/doctor-my',
          })
        }, 2000)
      }
    })
  },
  getnameValue: function(e) {
   
    this.setData({
      accountName: e.detail.value
    })
  },
  getbanklValue: function(e) {
   
    this.setData({
      bankName: e.detail.value
    })
  },
  getmunberValue: function(e) {
  
    this.setData({
      bankNo: e.detail.value
    })
  },
  getaddressValue: function(e) {
  
    this.setData({
      bankDeposit: e.detail.value
    })
  },
})